package com.ruoyi.web.controller.xiaoshouchuku;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.xiaoshouchuku.domain.SalesOrder;
import com.ruoyi.xiaoshouchuku.domain.XiaoshouChuku;
import com.ruoyi.xiaoshouchuku.dto.SalesOrderDto;
import com.ruoyi.xiaoshouchuku.service.ISalesOrderService;
import com.ruoyi.xiaoshouchuku.service.impl.SalesOrderServiceImpl;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/xiaoshou/salesOrder")
public class SalesOrderController extends BaseController {

    @Autowired
    private ISalesOrderService salesOrderService;

    @PostMapping
    @Log(title = "销售出库", businessType = BusinessType.INSERT)
    public AjaxResult add(@RequestBody SalesOrderDto salesOrderDto)
    {
        salesOrderDto.setSalesPerson(getLoginUser().getUser().getNickName());
        return toAjax(salesOrderService.insertSalesOrder(salesOrderDto));
    }

    /**
     * 查询列表
     */
    @GetMapping("/list")
    public TableDataInfo list(SalesOrder salesOrder)
    {
        startPage();
        List<SalesOrder> list = salesOrderService.selectOrderList(salesOrder);
        return getDataTable(list);
    }


}
